<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Chapter 17 Graphics including GenomeDiagram &mdash; Biopython_en 1.0 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '1.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Biopython_en 1.0 documentation" href="index.html" />
    <link rel="next" title="Chapter 18 Cookbook – Cool things to do with it" href="chr18.html" />
    <link rel="prev" title="Chapter 16 Supervised learning methods" href="chr16.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="chr18.html" title="Chapter 18 Cookbook – Cool things to do with it"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="chr16.html" title="Chapter 16 Supervised learning methods"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Biopython_en 1.0 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="chapter-17-graphics-including-genomediagram">
<h1>Chapter 17  Graphics including GenomeDiagram<a class="headerlink" href="#chapter-17-graphics-including-genomediagram" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="docutils literal"><span class="pre">Bio.Graphics</span></tt> module depends on the third party Python library
<a class="reference external" href="http://www.reportlab.org">ReportLab</a>. Although focused on producing
PDF files, ReportLab can also create encapsulated postscript (EPS) and
(SVG) files. In addition to these vector based images, provided certain
further dependencies such as the <a class="reference external" href="http://www.pythonware.com/products/pil/">Python Imaging Library
(PIL)</a> are installed,
ReportLab can also output bitmap images (including JPEG, PNG, GIF, BMP
and PICT formats).</p>
<div class="section" id="genomediagram">
<h2>17.1  GenomeDiagram<a class="headerlink" href="#genomediagram" title="Permalink to this headline">¶</a></h2>
<div class="section" id="introduction">
<h3>17.1.1  Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h3>
<p>The <tt class="docutils literal"><span class="pre">Bio.Graphics.GenomeDiagram</span></tt> module was added to Biopython 1.50,
having previously been available as a separate Python module dependent
on Biopython. GenomeDiagram is described in the Bioinformatics journal
publication by Pritchard et al. (2006) [<a class="reference external" href="#pritchard2006">2</a>], which
includes some examples images. There is a PDF copy of the old manual
here,
<tt class="docutils literal"><span class="pre">`http://biopython.org/DIST/docs/GenomeDiagram/userguide.pdf</span></tt> &lt;<a class="reference external" href="http://biopython.org/DIST/docs/GenomeDiagram/userguide.pdf">http://biopython.org/DIST/docs/GenomeDiagram/userguide.pdf</a>&gt;`__
which has some more examples. As the name might suggest, GenomeDiagram
was designed for drawing whole genomes, in particular prokaryotic
genomes, either as linear diagrams (optionally broken up into fragments
to fit better) or as circular wheel diagrams. Have a look at Figure 2 in
Toth <em>et al.</em> (2006) [<a class="reference external" href="#toth2006">3</a>] for a good example. It proved
also well suited to drawing quite detailed figures for smaller genomes
such as phage, plasmids or mitochrondia, for example see Figures 1 and 2
in Van der Auwera <em>et al.</em> (2009) [<a class="reference external" href="#vanderauwera2009">4</a>] (shown
with additional manual editing).</p>
<p>This module is easiest to use if you have your genome loaded as a
<tt class="docutils literal"><span class="pre">SeqRecord</span></tt> object containing lots of <tt class="docutils literal"><span class="pre">SeqFeature</span></tt> objects - for
example as loaded from a GenBank file (see
Chapters <a class="reference external" href="#chapter:SeqRecord">4</a> and <a class="reference external" href="#chapter:Bio.SeqIO">5</a>).</p>
</div>
<div class="section" id="diagrams-tracks-feature-sets-and-features">
<h3>17.1.2  Diagrams, tracks, feature-sets and features<a class="headerlink" href="#diagrams-tracks-feature-sets-and-features" title="Permalink to this headline">¶</a></h3>
<p>GenomeDiagram uses a nested set of objects. At the top level, you have a
diagram object representing a sequence (or sequence region) along the
horizontal axis (or circle). A diagram can contain one or more tracks,
shown stacked vertically (or radially on circular diagrams). These will
typically all have the same length and represent the same sequence
region. You might use one track to show the gene locations, another to
show regulatory regions, and a third track to show the GC percentage.
The most commonly used type of track will contain features, bundled
together in feature-sets. You might choose to use one feature-set for
all your CDS features, and another for tRNA features. This isn’t
required - they can all go in the same feature-set, but it makes it
easier to update the properties of just selected features (e.g. make all
the tRNA features red).</p>
<p>There are two main ways to build up a complete diagram. Firstly, the top
down approach where you create a diagram object, and then using its
methods add track(s), and use the track methods to add feature-set(s),
and use their methods to add the features. Secondly, you can create the
individual objects separately (in whatever order suits your code), and
then combine them.</p>
</div>
<div class="section" id="a-top-down-example">
<h3>17.1.3  A top down example<a class="headerlink" href="#a-top-down-example" title="Permalink to this headline">¶</a></h3>
<p>We’re going to draw a whole genome from a <tt class="docutils literal"><span class="pre">SeqRecord</span></tt> object read in
from a GenBank file (see Chapter <a class="reference external" href="#chapter:Bio.SeqIO">5</a>). This
example uses the pPCP1 plasmid from <em>Yersinia pestis biovar Microtus</em>,
the file is included with the Biopython unit tests under the GenBank
folder, or online
<tt class="docutils literal"><span class="pre">`NC_005816.gb</span></tt> &lt;<a class="reference external" href="http://biopython.org/SRC/biopython/Tests/GenBank/NC_005816.gb">http://biopython.org/SRC/biopython/Tests/GenBank/NC_005816.gb</a>&gt;`__
from our website.</p>
<p>We’re using a top down approach, so after loading in our sequence we
next create an empty diagram, then add an (empty) track, and to that add
an (empty) feature set:</p>
<p>Now the fun part - we take each gene <tt class="docutils literal"><span class="pre">SeqFeature</span></tt> object in our
<tt class="docutils literal"><span class="pre">SeqRecord</span></tt>, and use it to generate a feature on the diagram. We’re
going to color them blue, alternating between a dark blue and a light
blue.</p>
<p>Now we come to actually making the output file. This happens in two
steps, first we call the <tt class="docutils literal"><span class="pre">draw</span></tt> method, which creates all the shapes
using ReportLab objects. Then we call the <tt class="docutils literal"><span class="pre">write</span></tt> method which renders
these to the requested file format. Note you can output in multiple file
formats:</p>
<p>Also, provided you have the dependencies installed, you can also do
bitmaps, for example:</p>
<p><a href="#id1"><span class="problematic" id="id2">|image13|</span></a></p>
<p>Notice that the <tt class="docutils literal"><span class="pre">fragments</span></tt> argument which we set to four controls how
many pieces the genome gets broken up into.</p>
<p>If you want to do a circular figure, then try this:</p>
<p><a href="#id3"><span class="problematic" id="id4">|image14|</span></a></p>
<p>These figures are not very exciting, but we’ve only just got started.</p>
</div>
<div class="section" id="a-bottom-up-example">
<h3>17.1.4  A bottom up example<a class="headerlink" href="#a-bottom-up-example" title="Permalink to this headline">¶</a></h3>
<p>Now let’s produce exactly the same figures, but using the bottom up
approach. This means we create the different objects directly (and this
can be done in almost any order) and then combine them.</p>
<p>You can now call the <tt class="docutils literal"><span class="pre">draw</span></tt> and <tt class="docutils literal"><span class="pre">write</span></tt> methods as before to produce
a linear or circular diagram, using the code at the end of the top-down
example above. The figures should be identical.</p>
</div>
<div class="section" id="features-without-a-seqfeature">
<h3>17.1.5  Features without a SeqFeature<a class="headerlink" href="#features-without-a-seqfeature" title="Permalink to this headline">¶</a></h3>
<p>In the above example we used a <tt class="docutils literal"><span class="pre">SeqRecord</span></tt>’s <tt class="docutils literal"><span class="pre">SeqFeature</span></tt> objects
to build our diagram (see also Section <a class="reference external" href="#sec:seq_features">4.3</a>).
Sometimes you won’t have <tt class="docutils literal"><span class="pre">SeqFeature</span></tt> objects, but just the
coordinates for a feature you want to draw. You have to create minimal
<tt class="docutils literal"><span class="pre">SeqFeature</span></tt> object, but this is easy:</p>
<p>For strand, use <tt class="docutils literal"><span class="pre">+1</span></tt> for the forward strand, <tt class="docutils literal"><span class="pre">-1</span></tt> for the reverse
strand, and <tt class="docutils literal"><span class="pre">None</span></tt> for both. Here is a short self contained example:</p>
<p>The top part of the image in the next subsection shows the output (in
the default feature color, pale green).</p>
<p>Notice that we have used the <tt class="docutils literal"><span class="pre">name</span></tt> argument here to specify the
caption text for these features. This is discussed in more detail next.</p>
</div>
<div class="section" id="feature-captions">
<h3>17.1.6  Feature captions<a class="headerlink" href="#feature-captions" title="Permalink to this headline">¶</a></h3>
<p>Recall we used the following (where <tt class="docutils literal"><span class="pre">feature</span></tt> was a <tt class="docutils literal"><span class="pre">SeqFeature</span></tt>
object) to add a feature to the diagram:</p>
<p>In the example above the <tt class="docutils literal"><span class="pre">SeqFeature</span></tt> annotation was used to pick a
sensible caption for the features. By default the following possible
entries under the <tt class="docutils literal"><span class="pre">SeqFeature</span></tt> object’s qualifiers dictionary are
used: <tt class="docutils literal"><span class="pre">gene</span></tt>, <tt class="docutils literal"><span class="pre">label</span></tt>, <tt class="docutils literal"><span class="pre">name</span></tt>, <tt class="docutils literal"><span class="pre">locus_tag</span></tt>, and <tt class="docutils literal"><span class="pre">product</span></tt>.
More simply, you can specify a name directly:</p>
<p>In addition to the caption text for each feature’s label, you can also
choose the font, position (this defaults to the start of the sigil, you
can also choose the middle or at the end) and orientation (for linear
diagrams only, where this defaults to rotated by 45 degrees):</p>
<p>Combining each of these three fragments with the complete example in the
previous section should give something like this:</p>
<p><a href="#id5"><span class="problematic" id="id6">|image15|</span></a></p>
<p>We’ve not shown it here, but you can also set <tt class="docutils literal"><span class="pre">label_color</span></tt> to control
the label’s color (used in Section <a class="reference external" href="#sec:gd_nice_example">17.1.9</a>).</p>
<p>You’ll notice the default font is quite small - this makes sense because
you will usually be drawing many (small) features on a page, not just a
few large ones as shown here.</p>
</div>
<div class="section" id="feature-sigils">
<h3>17.1.7  Feature sigils<a class="headerlink" href="#feature-sigils" title="Permalink to this headline">¶</a></h3>
<p>The examples above have all just used the default sigil for the feature,
a plain box, which was all that was available in the last publicly
released standalone version of GenomeDiagram. Arrow sigils were included
when GenomeDiagram was added to Biopython 1.50:</p>
<p>Biopython 1.61 added three more sigils,</p>
<p>These are shown below. Most sigils fit into a bounding box (as given by
the default BOX sigil), either above or below the axis for the forward
or reverse strand, or straddling it (double the height) for strand-less
features. The BIGARROW sigil is different, always straddling the axis
with the direction taken from the feature’s stand.</p>
<p><a href="#id7"><span class="problematic" id="id8">|image16|</span></a></p>
</div>
<div class="section" id="arrow-sigils">
<h3>17.1.8  Arrow sigils<a class="headerlink" href="#arrow-sigils" title="Permalink to this headline">¶</a></h3>
<p>We introduced the arrow sigils in the previous section. There are two
additional options to adjust the shapes of the arrows, firstly the
thickness of the arrow shaft, given as a proportion of the height of the
bounding box:</p>
<p>The results are shown below:</p>
<p><a href="#id9"><span class="problematic" id="id10">|image17|</span></a></p>
<p>Secondly, the length of the arrow head - given as a proportion of the
height of the bounding box (defaulting to 0.5, or 50%):</p>
<p>The results are shown below:</p>
<p><a href="#id11"><span class="problematic" id="id12">|image18|</span></a></p>
<p>Biopython 1.61 adds a new <tt class="docutils literal"><span class="pre">BIGARROW</span></tt> sigil which always stradles the
axis, pointing left for the reverse strand or right otherwise:</p>
<p>All the shaft and arrow head options shown above for the <tt class="docutils literal"><span class="pre">ARROW</span></tt> sigil
can be used for the <tt class="docutils literal"><span class="pre">BIGARROW</span></tt> sigil too.</p>
</div>
<div class="section" id="a-nice-example">
<h3>17.1.9  A nice example<a class="headerlink" href="#a-nice-example" title="Permalink to this headline">¶</a></h3>
<p>Now let’s return to the pPCP1 plasmid from <em>Yersinia pestis biovar
Microtus</em>, and the top down approach used in
Section <a class="reference external" href="#sec:gd_top_down">17.1.3</a>, but take advantage of the sigil
options we’ve now discussed. This time we’ll use arrows for the genes,
and overlay them with strand-less features (as plain boxes) showing the
position of some restriction digest sites.</p>
<p>And the output:</p>
<p><a href="#id13"><span class="problematic" id="id14">|image19|</span></a></p>
<p><a href="#id15"><span class="problematic" id="id16">|image20|</span></a></p>
</div>
<div class="section" id="multiple-tracks">
<h3>17.1.10  Multiple tracks<a class="headerlink" href="#multiple-tracks" title="Permalink to this headline">¶</a></h3>
<p>All the examples so far have used a single track, but you can have more
than one track – for example show the genes on one, and repeat regions
on another. In this example we’re going to show three phage genomes side
by side to scale, inspired by Figure 6 in Proux <em>e</em>t al. (2002)
[<a class="reference external" href="#proux2002">5</a>]. We’ll need the GenBank files for the following
three phage:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">NC_002703</span></tt> – Lactococcus phage Tuc2009, complete genome (38347 bp)</li>
<li><tt class="docutils literal"><span class="pre">AF323668</span></tt> – Bacteriophage bIL285, complete genome (35538 bp)</li>
<li><tt class="docutils literal"><span class="pre">NC_003212</span></tt> – <em>Listeria innocua</em> Clip11262, complete genome, of
which we are focussing only on integrated prophage 5 (similar
length).</li>
</ul>
<p>You can download these using Entrez if you like, see
Section <a class="reference external" href="#sec:efetch">9.6</a> for more details. For the third record
we’ve worked out where the phage is integrated into the genome, and
slice the record to extract it (with the features preserved, see
Section <a class="reference external" href="#sec:SeqRecord-slicing">4.6</a>), and must also reverse
complement to match the orientation of the first two phage (again
preserving the features, see
Section <a class="reference external" href="#sec:SeqRecord-reverse-complement">4.8</a>):</p>
<p>The figure we are imitating used different colors for different gene
functions. One way to do this is to edit the GenBank file to record
color preferences for each feature - something <a class="reference external" href="http://www.sanger.ac.uk/resources/software/artemis/">Sanger’s Artemis
editor</a> does,
and which GenomeDiagram should understand. Here however, we’ll just hard
code three lists of colors.</p>
<p>Note that the annotation in the GenBank files doesn’t exactly match that
shown in Proux <em>et al.</em>, they have drawn some unannotated genes.</p>
<p>Now to draw them – this time we add three tracks to the diagram, and
also notice they are given different start/end values to reflect their
different lengths (this requires Biopython 1.59 or later).</p>
<p>The result:</p>
<p><a href="#id17"><span class="problematic" id="id18">|image21|</span></a></p>
<p>I did wonder why in the original manuscript there were no red or orange
genes marked in the bottom phage. Another important point is here the
phage are shown with different lengths - this is because they are all
drawn to the same scale (they <em>are</em> different lengths).</p>
<p>The key difference from the published figure is they have color-coded
links between similar proteins – which is what we will do in the next
section.</p>
</div>
<div class="section" id="cross-links-between-tracks">
<h3>17.1.11  Cross-Links between tracks<a class="headerlink" href="#cross-links-between-tracks" title="Permalink to this headline">¶</a></h3>
<p>Biopython 1.59 added the ability to draw cross links between tracks -
both simple linear diagrams as we will show here, but also linear
diagrams split into fragments and circular diagrams.</p>
<p>Continuing the example from the previous section inspired by Figure 6
from Proux <em>et al.</em> 2002 [<a class="reference external" href="#proux2002">5</a>], we would need a list of
cross links between pairs of genes, along with a score or color to use.
Realistically you might extract this from a BLAST file computationally,
but here I have manually typed them in.</p>
<p>My naming convention continues to refer to the three phage as A, B and
C. Here are the links we want to show between A and B, given as a list
of tuples (percentage similarity score, gene in A, gene in B).</p>
<p>Likewise for B and C:</p>
<p>For the first and last phage these identifiers are locus tags, for the
middle phage there are no locus tags so I’ve used gene names instead.
The following little helper function lets us lookup a feature using
either a locus tag or gene name:</p>
<p>We can now turn those list of identifier pairs into SeqFeature pairs,
and thus find their location co-ordinates. We can now add all that code
and the following snippet to the previous example (just before the
<tt class="docutils literal"><span class="pre">gd_diagram.draw(...)</span></tt> line – see the finished example script
<a class="reference external" href="http://biopython.org/SRC/biopython/Doc/examples/Proux_et_al_2002_Figure_6.py">Proux_et_al_2002_Figure_6.py</a>
included in the <tt class="docutils literal"><span class="pre">Doc/examples</span></tt> folder of the Biopython source code) to
add cross links to the figure:</p>
<p>There are several important pieces to this code. First the
<tt class="docutils literal"><span class="pre">GenomeDiagram</span></tt> object has a <tt class="docutils literal"><span class="pre">cross_track_links</span></tt> attribute which is
just a list of <tt class="docutils literal"><span class="pre">CrossLink</span></tt> objects. Each <tt class="docutils literal"><span class="pre">CrossLink</span></tt> object takes
two sets of track-specific co-ordinates (here given as tuples, you can
alternatively use a <tt class="docutils literal"><span class="pre">GenomeDiagram.Feature</span></tt> object instead). You can
optionally supply a colour, border color, and say if this link should be
drawn flipped (useful for showing inversions).</p>
<p>You can also see how we turn the BLAST percentage identity score into a
colour, interpolating between white (0%) and a dark red (100%). In this
example we don’t have any problems with overlapping cross-links. One way
to tackle that is to use transparency in ReportLab, by using colors with
their alpha channel set. However, this kind of shaded color scheme
combined with overlap transparency would be difficult to interpret. The
result:</p>
<p><a href="#id19"><span class="problematic" id="id20">|image22|</span></a></p>
<p>There is still a lot more that can be done within Biopython to help
improve this figure. First of all, the cross links in this case are
between proteins which are drawn in a strand specific manor. It can help
to add a background region (a feature using the ‘BOX’ sigil) on the
feature track to extend the cross link. Also, we could reduce the
vertical height of the feature tracks to allocate more to the links
instead – one way to do that is to allocate space for empty tracks.
Furthermore, in cases like this where there are no large gene overlaps,
we can use the axis-straddling <tt class="docutils literal"><span class="pre">BIGARROW</span></tt> sigil, which allows us to
further reduce the vertical space needed for the track. These
improvements are demonstrated in the example script
<a class="reference external" href="http://biopython.org/SRC/biopython/Doc/examples/Proux_et_al_2002_Figure_6.py">Proux_et_al_2002_Figure_6.py</a>
included in the <tt class="docutils literal"><span class="pre">Doc/examples</span></tt> folder of the Biopython source code.
The result:</p>
<p><a href="#id21"><span class="problematic" id="id22">|image23|</span></a></p>
<p>Beyond that, finishing touches you might want to do manually in a vector
image editor include fine tuning the placement of gene labels, and
adding other custom annotation such as highlighting particular regions.</p>
<p>Although not really necessary in this example since none of the
cross-links overlap, using a transparent color in ReportLab is a very
useful technique for superimposing multiple links. However, in this case
a shaded color scheme should be avoided.</p>
</div>
<div class="section" id="further-options">
<h3>17.1.12  Further options<a class="headerlink" href="#further-options" title="Permalink to this headline">¶</a></h3>
<p>You can control the tick marks to show the scale – after all every graph
should show its units, and the number of the grey-track labels.</p>
<p>Also, we have only used the <tt class="docutils literal"><span class="pre">FeatureSet</span></tt> so far. GenomeDiagram also
has a <tt class="docutils literal"><span class="pre">GraphSet</span></tt> which can be used for show line graphs, bar charts
and heat plots (e.g. to show plots of GC% on a track parallel to the
features).</p>
<p>These options are not covered here yet, so for now we refer you to the
<a class="reference external" href="http://biopython.org/DIST/docs/GenomeDiagram/userguide.pdf">User Guide
(PDF)</a>
included with the standalone version of GenomeDiagram (but please read
the next section first), and the docstrings.</p>
</div>
<div class="section" id="converting-old-code">
<h3>17.1.13  Converting old code<a class="headerlink" href="#converting-old-code" title="Permalink to this headline">¶</a></h3>
<p>If you have old code written using the standalone version of
GenomeDiagram, and you want to switch it over to using the new version
included with Biopython then you will have to make a few changes - most
importantly to your import statements.</p>
<p>Also, the older version of GenomeDiagram used only the UK spellings of
color and center (colour and centre). As part of the integration into
Biopython, both forms can now be used for argument names. However, at
some point in the future the UK spellings may be deprecated.</p>
<p>For example, if you used to have:</p>
<p>you could just switch the import statements like this:</p>
<p>and hopefully that should be enough. In the long term you might want to
switch to the new names, but you would have to change more of your code:</p>
<p>or:</p>
<p>If you run into difficulties, please ask on the Biopython mailing list
for advice. One catch is that we have not included the old module
<tt class="docutils literal"><span class="pre">GenomeDiagram.GDUtilities</span></tt> yet. This included a number of GC% related
functions, which will probably be merged under <tt class="docutils literal"><span class="pre">Bio.SeqUtils</span></tt> later
on.</p>
</div>
</div>
<div class="section" id="chromosomes">
<h2>17.2  Chromosomes<a class="headerlink" href="#chromosomes" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">Bio.Graphics.BasicChromosome</span></tt> module allows drawing of
chromosomes. There is an example in Jupe <em>et al.</em> (2012)
[<a class="reference external" href="#jupe2012">6</a>] (open access) using colors to highlight different
gene families.</p>
<div class="section" id="simple-chromosomes">
<h3>17.2.1  Simple Chromosomes<a class="headerlink" href="#simple-chromosomes" title="Permalink to this headline">¶</a></h3>
<p>Here is a very simple example - for which we’ll use <em>Arabidopsis
thaliana</em>.</p>
<p>You can skip this bit, but first I downloaded the five sequenced
chromosomes from the NCBI’s FTP site
<tt class="docutils literal"><span class="pre">`ftp://ftp.ncbi.nlm.nih.gov/genomes/Arabidopsis_thaliana</span></tt> &lt;<a class="reference external" href="ftp://ftp.ncbi.nlm.nih.gov/genomes/Arabidopsis_thaliana">ftp://ftp.ncbi.nlm.nih.gov/genomes/Arabidopsis_thaliana</a>&gt;`__
and then parsed them with <tt class="docutils literal"><span class="pre">Bio.SeqIO</span></tt> to find out their lengths. You
could use the GenBank files for this, but it is faster to use the FASTA
files for the whole chromosomes:</p>
<p>This gave the lengths of the five chromosomes, which we’ll now use in
the following short demonstration of the <tt class="docutils literal"><span class="pre">BasicChromosome</span></tt> module:</p>
<p>This should create a very simple PDF file, shown here:</p>
<p><a href="#id23"><span class="problematic" id="id24">|image24|</span></a></p>
<p>This example is deliberately short and sweet. The next example shows the
location of features of interest.</p>
</div>
<div class="section" id="annotated-chromosomes">
<h3>17.2.2  Annotated Chromosomes<a class="headerlink" href="#annotated-chromosomes" title="Permalink to this headline">¶</a></h3>
<p>Continuing from the previous example, let’s also show the tRNA genes.
We’ll get their locations by parsing the GenBank files for the five
<em>Arabidopsis thaliana</em> chromosomes. You’ll need to download these files
from the NCBI FTP site
<tt class="docutils literal"><span class="pre">`ftp://ftp.ncbi.nlm.nih.gov/genomes/Arabidopsis_thaliana</span></tt> &lt;<a class="reference external" href="ftp://ftp.ncbi.nlm.nih.gov/genomes/Arabidopsis_thaliana">ftp://ftp.ncbi.nlm.nih.gov/genomes/Arabidopsis_thaliana</a>&gt;`__,
and preserve the subdirectory names or edit the paths below:</p>
<p>It might warn you about the labels being too close together - have a
look at the forward strand (right hand side) of Chr I, but it should
create a colorful PDF file, shown here:</p>
<p><a href="#id25"><span class="problematic" id="id26">|image25|</span></a></p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Chapter 17  Graphics including GenomeDiagram</a><ul>
<li><a class="reference internal" href="#genomediagram">17.1  GenomeDiagram</a><ul>
<li><a class="reference internal" href="#introduction">17.1.1  Introduction</a></li>
<li><a class="reference internal" href="#diagrams-tracks-feature-sets-and-features">17.1.2  Diagrams, tracks, feature-sets and features</a></li>
<li><a class="reference internal" href="#a-top-down-example">17.1.3  A top down example</a></li>
<li><a class="reference internal" href="#a-bottom-up-example">17.1.4  A bottom up example</a></li>
<li><a class="reference internal" href="#features-without-a-seqfeature">17.1.5  Features without a SeqFeature</a></li>
<li><a class="reference internal" href="#feature-captions">17.1.6  Feature captions</a></li>
<li><a class="reference internal" href="#feature-sigils">17.1.7  Feature sigils</a></li>
<li><a class="reference internal" href="#arrow-sigils">17.1.8  Arrow sigils</a></li>
<li><a class="reference internal" href="#a-nice-example">17.1.9  A nice example</a></li>
<li><a class="reference internal" href="#multiple-tracks">17.1.10  Multiple tracks</a></li>
<li><a class="reference internal" href="#cross-links-between-tracks">17.1.11  Cross-Links between tracks</a></li>
<li><a class="reference internal" href="#further-options">17.1.12  Further options</a></li>
<li><a class="reference internal" href="#converting-old-code">17.1.13  Converting old code</a></li>
</ul>
</li>
<li><a class="reference internal" href="#chromosomes">17.2  Chromosomes</a><ul>
<li><a class="reference internal" href="#simple-chromosomes">17.2.1  Simple Chromosomes</a></li>
<li><a class="reference internal" href="#annotated-chromosomes">17.2.2  Annotated Chromosomes</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="chr16.html"
                        title="previous chapter">Chapter 16  Supervised learning methods</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="chr18.html"
                        title="next chapter">Chapter 18  Cookbook – Cool things to do with it</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/chr17.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="chr18.html" title="Chapter 18 Cookbook – Cool things to do with it"
             >next</a> |</li>
        <li class="right" >
          <a href="chr16.html" title="Chapter 16 Supervised learning methods"
             >previous</a> |</li>
        <li><a href="index.html">Biopython_en 1.0 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2013, Biopython.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b1.
    </div>
  </body>
</html>